home
***
CD-ROM
|
disk
|
FTP
|
other
***
search
/
Video Toaster 4.3
/
Video Toaster v4.3.iso
/
3.1
/
toasterall
/
arexx_examples
/
tpaint
/
txbrush.rexx
< prev
next >
Wrap
OS/2 REXX Batch file
|
1992-01-29
|
4KB
|
117 lines
/* TxBrush.rexx -- Resize a brush to be a multiple of 64 pixels wide */
/* By Arnie Cachelin © 1992 NewTek Inc. */
/*
This program will resize a brush so that the width is a multiple of 64 pixels
for use as texture map in LightWave3D. You must tell it the width and
height of the brush, along with its name. The height won't be changed.
To use the program, make sure TPaint is running, rexx is installed and
this script is in the current directory or in 'REXX:'. From a shell,
simply type 'rx TxBrush w h name'. Where w is the brush width, h is the
height and name is the file name for the brush. If a second name is given,
the brush will be saved with that name otherwise the brush will be saved
under the same name with '.map' appended. The width of a brush can be
determined by clicking the right mouse button in paint.
*/
ARG w h infile outfile
if w="" | h="" | infile="" then do
say "Usage: rx TxBrush w h name [save name]"
say " w = brush width in pixels"
say " h = brush height in pixels"
say " name = brush file name"
exit
end
PageWide=752
PageHigh=480
maxsize=704
portname="DigiPaint"
Address "DigiPaint" /* Tell ARexx where commands go */
if pos(portname,show(ports))=0 then do
say "Can't find ToasterPaint!"
exit
end
if infile~="" then do
if ~exists(infile) then do
say "Can't find input image file "infile
exit
end
Call LoadBrush(infile) /* if no name is given, use current screen! */
if outfile="" then outfile=infile".map"
end
if w>pagewide then size=maxsize
else size=(w%64+1)*64
'Bcop' /* Copy brush to Swap brush */
'Cbx0' /* Set color to black */
'Clrs' /* Clear screen */
call MapBrush(0,0,size-1,h-1)
call CutBrush(0,0,size-1,h-1)
Call SaveBrush(outfile)
exit
MapBrush: PROCEDURE /* Size swap brush into rectangle with corners at (x1,y1) and (x2,y2) */
arg x1, y1, x2, y2 /* if there is no swap brush, whole screen is used! */
'Pmcl' /* Normal draw Mode */
'Hvof' /* Blend gradient off (edge=center) */
'Maxc' /* Set (center) transparency off */
'Flon' /* Fill On */
'Aaon' /* Anti-alias on */
'Txma' /* Texture mapping on, fill on, draw rectangles */
'Drre' /* Draw Rectangles */
'Pend' x1 y1 /* Get in top Left corner */
'Penu' x2 y2 /* lift pen */
'Flof' /* fill off */
'Pmcl' /* Normal draw Mode */
return
CutBrush: PROCEDURE /* Cut out a brush with corners at (x1,y1) and (x2,y2) */
arg x1, y1, x2, y2
'Dotb' /* smallest brush size */
'Drre' /* Rectangle mode */
'Scis' /* Scissors on, for cutting a brush */
'Pend' x1 y1 /* Get in top Left corner */
'Penu' x2 y2 /* lift pen to get brush! */
return 0
LoadBrush: PROCEDURE /* Load Brush */
arg filename
'Lobr' /* Call file requester */
Call SetFile(filename)
return
SaveBrush: PROCEDURE /* Save Brush */
arg filename
'Sabr' /* Call file requester */
Call SetFile(filename)
return
SetFile: PROCEDURE /* Select file in current requester */
arg file
dirname=GetPathName(file)
'Dnam'dirname /* Enter file path */
'Dsel' /* Hit return on directory */
filename=GetFileName(file)
'Fnam'filename /* Enter File name */
'Okls' /* Hit the OK button */
return
GetFileName: procedure /* Extract file name from full file specification */
ARG fullfile
c = lastpos("/",fullfile)
if c = 0 then c = lastpos(":",fullfile)
return substr(fullfile, c + 1)
GetPathName: procedure /* Extract directory name from full file specification */
ARG fullfile
c = lastpos("/",fullfile)
if c = 0 then c = lastpos(":",fullfile)
return left(fullfile,c)